﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Calculatorwithclass
{
    public partial class Form1 : Form
    {
        Calc calculator;
        public Form1()
        {
            InitializeComponent();
            calculator = new Calc();
        }

        private void button1_Click(object sender, EventArgs e)
        {
//            calculator.Add(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text));

            SetValues();
            calculator.Add();
            label1.Text = calculator.Result.ToString();

            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SetValues();
            calculator.Sub();
            SetResult();
        }


        private void SetValues()
        {
            calculator.Value1 = Convert.ToInt32(textBox1.Text);
            calculator.Value2 = Convert.ToInt32(textBox2.Text);
        }
        private void SetResult()
        {
            label1.Text = calculator.Result.ToString();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            SetValues();
            calculator.Mul();
            SetResult();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            SetValues();
            calculator.Div();
            SetResult();
        }
    }
}
